<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Insert title here</title>
<meta charset="UTF-8">
<base th:href="@{/}" />
<script src="js/jquery-3.4.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/Managerstyle.css" />
<style>
span{
	padding: 7px;
}
form{
	text-align: center;
}
</style>
</head>
<body>
	<div class="contain">
		<h3>评教</h3>
		<form id="ss">
			<input type="text" th:value="${session.loginStudent.srollno}" name="srollno" hidden />
			<input type="text" th:value="${session.currentTerm.term.termId}" name="termId" hidden />
			<table class="table">
				<tr>
					<td>教师姓名</td>
					<td>课程名称</td>
					<td>评价</td>
				</tr>	
				<tr th:each="coursePlan:${coursePlanList}">
					<td>
						[[${coursePlan.teacher.tname}]]
						<input type="text" th:value="${coursePlan.teacher.tid}" name="tid" hidden />
					</td>
					<td>[[${coursePlan.lessionPlan.course.cname}]]
						<input type="text" th:value="${coursePlan.lessionPlan.course.cid}" name="cid" hidden />
					</td>
					
					<td>
						<input type="radio"	th:name="grade+${coursePlan.cpid}" class="class" value="0" /><span>不满意</span>
						<input type="radio" th:name="grade+${coursePlan.cpid}" class="class" value="1" /><span>满意</span>
						<input type="radio" th:name="grade+${coursePlan.cpid}" class="class" value="2" /><span>非常满意</span>
					</td>
				</tr>
			</table>
			<button id="button1" class="btn btn-primary" type="button" >提交</button>
		</form>
	</div>
	<script>
		$(document).ready(function() {
			$("#button1").click(function(){
				var a = $(".class");
				var str1 = "";
				var count = 0;
				for (var i = 0; i < a.length; i++) {
					if (a[i].checked) {
						str1 = str1 + "&grade=" + $(a[i]).val();
						count++;
					}
				}
				var b = a.length/3;
				if(b == count){
					$.ajax({
						url: "stu/submitResult",
						type: "GET",
						data: $("#ss").serialize() + str1,
						success: function(){
							alert("评价完成");
							top.location.reload();
						},
						error: function(){
							
						}
					}); 
				}else{
					alert("没选完");
				}
				
			});
		});
	</script>


</body>
</html>